package com.hunting.resume;

import java.util.List;

import javax.servlet.http.HttpSession;

import org.apache.struts2.ServletActionContext;

import com.hunting.agl.login.Login;
import com.hunting.company.ResumeCompany;
import com.hunting.company.ResumeCompanyDao;



import com.opensymphony.xwork2.ActionSupport;

public class ResumeAction extends ActionSupport{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	private Resume resume;
	private ResumeDao resumeDao;
	private long id;
	private List<Resume> list;
	HttpSession session ;
	private long user_id;
	private ResumeCompany resumeCompany;
	private ResumeCompanyDao resumeCompanyDao;
	
	public Resume getResume() {
		return resume;
	}
	public void setResume(Resume resume) {
		this.resume = resume;
	}
	
	public String start() throws Exception{
		return SUCCESS;
	}
	public String saveResume() throws Exception{
		session = ServletActionContext.getRequest().getSession();
//		session.getAttribute("id");
		this.resume.setUser_id((Long)session.getAttribute("id"));
		System.out.println("+++++++++"+this.resume.getUser_id());
		this.resumeDao.saveOrUpdate(this.resume);
		return SUCCESS;
	} 
	public String showResume() throws Exception{
		resume = this.resumeDao.findById(id);
		
		
		return SUCCESS;
	}
	private List <Resume> listes;
	public String showCompanyResume() throws Exception{
		session = ServletActionContext.getRequest().getSession();
		user_id= (Long)session.getAttribute("id");
		listes = this.resumeDao.findByuserId(user_id);
		return SUCCESS;
	}
	
	public String SavesuccessResume() throws Exception{
		resume = this.resumeDao.findById(id);
		resumeCompany =new ResumeCompany();
		resumeCompany.setName(resume.getName());
		resumeCompany.setSchool(resume.getSchool());
		resumeCompany.setUserName(resume.getUserName());
		this.resumeCompanyDao.saveOrUpdate(resumeCompany);
		return SUCCESS;
	}
	
	public String tt(){
		HttpSession session = ServletActionContext.getRequest().getSession();
		Login login = (Login) session.getAttribute("user");
		return "input";
	}
	
	public String showAllResume() throws Exception{
		list = this.resumeDao.findAll();
		return SUCCESS;
	}
	
	
	@Override
	public String execute() throws Exception {
		return SUCCESS;
	}
	public long getId() {
		return id;
	}
	public void setId(long id) {
		this.id = id;
	}
	public List<Resume> getList() {
		return list;
	}
	public void setList(List<Resume> list) {
		this.list = list;
	}
	
	
	public ResumeDao getResumeDao() {
		return resumeDao;
	}
	public void setResumeDao(ResumeDao resumeDao) {
		this.resumeDao = resumeDao;
	}
	public long getUser_id() {
		return user_id;
	}
	public void setUser_id(long user_id) {
		this.user_id = user_id;
	}
	public List<Resume> getListes() {
		return listes;
	}
	public void setListes(List<Resume> listes) {
		this.listes = listes;
	}
	public ResumeCompany getResumeCompany() {
		return resumeCompany;
	}
	public void setResumeCompany(ResumeCompany resumeCompany) {
		this.resumeCompany = resumeCompany;
	}
	public ResumeCompanyDao getResumeCompanyDao() {
		return resumeCompanyDao;
	}
	public void setResumeCompanyDao(ResumeCompanyDao resumeCompanyDao) {
		this.resumeCompanyDao = resumeCompanyDao;
	}
	
	

}
